package lc20240623;
/**
  * @description 求位1的个数
  * @author 不知名帅哥
  * @date 2024/6/23 22:57
  * @version 1.0
*/
public class BitOneNum {
    public int hammingWeight(int n) {
        int count=0;
        while (n!=0){
            int a = n & 1;
            if (a==1){
                count++;
            }
            n>>=1;
        }
        return count;
    }

    public static void main(String[] args) {
        int i = new BitOneNum().hammingWeight(7);
        System.out.println(i);
    }
}
